home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / os2 / zoc110.arj / ZOC / SCRIPT / QUEDIAL < prev    next >
Text File  |  1994-01-09  |  5KB  |  262 lines

  1. #########################################################
  2. #
  3. #    SCRIPT FOR FUNCTION MULTIDIAL AND CALLNEXT 
  4. #
  5. #   Thanks to Jay Sottolano for some improvements
  6. #    
  7. #########################################################
  8. #    
  9. #    If you select more than one entry to dial from the
  10. #    phonebook, they are stored in the file DIALQUE
  11. #    
  12. #    This script is automatically executed to connect
  13. #   to the first of these numbers. 
  14. #    CALLNEXT (from the Modem Menu) executes this script
  15. #   to connect to the next.
  16. #
  17. #########################################################
  18.  
  19.     debug 0; maxscan 5
  20.  
  21.     #    Read file and look if there's something in
  22.     call readfile
  23.     compn %max% with 1
  24.     ifhigh goto mbegin
  25.  
  26.     writeln "NOTHING MORE TO DO"
  27.     // shell   "del DIALQUE"
  28.     exit
  29.  
  30.  
  31. #####################################################
  32. #     MAIN LOOP
  33. #     
  34. :mbegin
  35.     #    begin with first
  36.  
  37.     send "AT^M"
  38.     delay 1
  39.  
  40.     setn q 0
  41.  
  42. :mloop0
  43.     cls
  44.     writeln "^[[1mQUEUE-DIAL (Abort with 'Stop Script' from toolbar)^[[m^M^J"
  45.     setn n 1
  46.     inc q
  47.  
  48. :mloop1
  49.  
  50.     #    Fetch data from record
  51.     seta name "%%box%n%%%"
  52.     seta boxdata "%name%"
  53.     seta box   "%boxdata%" |BOX=;  rtrim box
  54.     seta log   "%boxdata%" |LOG=;  rtrim log
  55.     seta emu   "%boxdata%" |EMU=;  rtrim emu
  56.     seta num   "%boxdata%" |TEL=;  rtrim num
  57.     seta baud  "%boxdata%" |PARM=; rtrim baud
  58.     seta opts  "%boxdata%" |OPTS=; rtrim baud
  59.     seta init  "%boxdata%" |INIT=; rtrim baud
  60.     seta zone  "%boxdata%" |ZONE=; rtrim zone
  61.     
  62.  
  63.     #    Call and wait for 90 sek. max
  64.     delay
  65.     writeln "Calling %box% ... Attempt #: %q%"
  66.     exact 1
  67.  
  68.     // wanna load options?
  69.     compa "%opts%" with ""
  70.     ifnequ loadopts "%opts%"
  71.  
  72.     // wanna init modem?
  73.     compa "%init%" with ""
  74.     ifnequ send "%init%"
  75.     ifnequ delay 2
  76.  
  77.     // want some emulation?
  78.     compa "%emu%" with ""
  79.     ifnequ setemu "%emu%"
  80.  
  81.     // parameters given?
  82.     compa "%baud%" with ""
  83.     ifnequ baud "%baud%"
  84.     ifnequ send ^M; 
  85.  
  86.     // set distance zone?
  87.     compa "%zone%" with ""
  88.     ifnequ setunit "%zone%"
  89.  
  90.     // so dial it ...
  91.     delay 1
  92.     dial "%num%^I%box%"
  93.     timeout 90;
  94.     
  95. :mloop2
  96.     waitline
  97.  
  98.     #    Timeout, nothing happened - go on
  99.     ifbrk hangup
  100.     ifbrk delay 2
  101.     ifbrk goto mgoon
  102.  
  103.     exact 0
  104.  
  105.     #    Zyxels say 'RINGING' - ignore that
  106.     compa "%lastline%" with RINGING
  107.     ifequ goto mloop2
  108.  
  109.     #    CONNECT, so login
  110.     compa "%lastline%" with CONNECT
  111.     ifequ goto mlogin
  112.  
  113.     compa "%lastline%" with CARRIER
  114.     ifequ goto mlogin
  115.  
  116.     #    For anything else, try again
  117.  
  118. :mgoon
  119.     #    Call next (or first again)
  120.     inc n 
  121.     compn %n% with %max%
  122.     ifnequ goto mloop1
  123.     goto mloop0
  124.        
  125. :mlogin
  126.     #    We're in
  127.     #    (delete records from list that are equal in the first six digits)
  128.     seta like "%box%" +1 6
  129.     call DelLike
  130.     call writefile
  131.  
  132.     #    OPERAAAATOR!
  133.     beep 3
  134.  
  135.     #    Did they want something to do for a start?
  136.     seta  cmd "%boxdata%" |CMD=
  137.     %cmd%
  138.  
  139.     #    Process W1/S1-loop
  140.     exact 1
  141.     setn n 1
  142.  
  143.     #    Set name for logging
  144.     compa "%log%" with ""
  145.     ifnequ logname "%log%"
  146.  
  147.     #    Answer to all Wx= with Sx= (see phonebook)
  148. :mlogloop
  149.     seta  w "%boxdata%" |W%n%=
  150.     seta  s "%boxdata%" |S%n%=
  151.     exact 1
  152.     compa "%w%" with ""
  153.     ifequ goto mfinish
  154.  
  155.     rtrim w
  156.     rtrim s
  157.  
  158.     wait "%w%"
  159.     ifbrk writeln "Error: Did not receive '%w%'!"
  160.     ifbrk goto mfinish
  161.  
  162.     delay
  163.     send "%s%"
  164.  
  165.     inc n
  166.     goto mlogloop
  167.  
  168. :mfinish
  169.     exit
  170. #
  171. #    END OF MAIN LOOP
  172. #####################################################
  173. #
  174. #
  175. #
  176. #    SUBS
  177. #
  178. #
  179. #
  180. ##################################
  181. #    READ FILE
  182. ##################################
  183. :readfile
  184. #
  185.     setn max 0 
  186.     openfile "DIALQUE" r
  187.     compa "%lastline%" with "##ERROR##"
  188.     ifequ writeln "Error"
  189.     ifequ return
  190.  
  191. :rloop
  192.     inc max
  193.     getfile
  194.     seta box%max% "%lastline%"
  195.     compa "%lastline%" with "##EOF##"
  196.     ifnequ goto rloop
  197.  
  198.     closefile
  199.     return
  200. ##################################
  201.  
  202.  
  203. ##################################
  204. #    WRITE FILE
  205. ##################################
  206. :writefile
  207. #
  208.     openfile "DIALQUE" w
  209.     setn n 1
  210.  
  211. :wloop
  212.     seta name %%box%n%%%
  213.     compa "%name%" with "##EOF##"
  214.     ifequ goto wend
  215.  
  216.     seta tmp "%name%" +1 1
  217.     compa %tmp% with *
  218.     ifequ goto wgoon
  219.     putfile "%name%"
  220. :wgoon
  221.     inc n; goto wloop
  222.  
  223. :wend
  224.     closefile 
  225.     return
  226. ##################################
  227.  
  228.  
  229. #####################################
  230. #    REPLACE ALL ENTRIES LIKE %LIKE% 
  231. #    WITH "*" 
  232. #####################################
  233. :DelLike
  234. #
  235.     setn i 1
  236.  
  237. :dloop
  238.     seta  dnam %%box%i%%%
  239.     seta  dname "%dnam%" |BOX=
  240.  
  241.     compa "%dname%" with "##EOF##"
  242.     ifequ goto dend
  243.  
  244.     compa "%like%" with "%dname%"
  245.     ifnequ goto dgoon
  246.  
  247.     seta box%i% *
  248.  
  249. :dgoon
  250.     inc i
  251.     goto dloop
  252.  
  253.  
  254. :dend
  255.     kill i
  256.     kill dnam
  257.     kill dname
  258.     kill like
  259.     return
  260.  
  261. #####################################
  262.